home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq21.zip / DIALBACK.SLT < prev    next >
Text File  |  1992-03-20  |  6KB  |  188 lines

  1. //-----------------------------------------------------------
  2. // DialBack.SL?    Telix script for dialback from ProDoor.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs, BEFORE you use it. Then recompile with CS DialBack.
  6. //-----------------------------------------------------------
  7.  
  8. // If you have suggestions for improving this script, please suggest
  9. // improvements to me via old-fashioned snail-mail to:
  10.  
  11. // Author:  Inge Vabekk
  12. //          Hamangskogen 108
  13. //          N-1300 SANDVIKA
  14. //          NORWAY
  15. //          tel. (472) 546 396
  16.  
  17. str thisBBStype[]="PCB"                  // Must be PCB to work. 
  18.    ,phone [32]                           // Phone number.
  19.    ,bbs_type  [32]                       // BBS type.
  20.                                          // Global names for:
  21.    ,DBack       [] = "DBACK"             // DialBack number.
  22.    ,global      [] = "GLOBAL"            // Name of Global script.
  23.    ,prompt      [] = "PROMPT"            // This BBS's command prompt.
  24.    ,bbstype     [] = "BTYPE"             // BBS type codeword.
  25.    ,command   [10]="Command:"            // Command prompt.
  26.    ;
  27. int tmark                                // Trig mark
  28.    ,tol=300                              // Time-out limit
  29.    ,t1                                   // Trig variables
  30.    ,t2
  31.    ;
  32.       
  33. //-----------------------------------------------------------
  34. // Script is entered here.                                   
  35. //-----------------------------------------------------------
  36.  
  37. main()
  38. {
  39. int c, i, j;
  40.  
  41.   entry();                               // Updates colors & status bar. 
  42.  
  43. // Only if online.
  44.  
  45.   if (!carrier())  
  46.   { failtone();
  47.     status_wind ("T²: THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  48.     return -1;
  49.   }
  50.   waitfor("numbers only :",2);
  51.   
  52.   cputc(8);                   // MUST send a backspace here!
  53.   delay(4);
  54.   update_term();              // Update screen.
  55.  
  56.   read (bbstype,bbs_type);               // Get BBS type.
  57.   if (bbs_type != thisBBStype)                                         
  58.   { wrongBBS();                          // Doesn't match script!
  59.     return -1;
  60.   }
  61.   read (prompt,command);                 // Get PCB command prompt.
  62.   read (Dback,phone);                    // Get DialBack number.
  63.  
  64.   for (i=0; i<strlen(phone); ++i)        // Send only the digits.
  65.   { c=subchr(phone,i);
  66.     if (isdigit(c)) cputc (c);
  67.   }
  68.   cputc ('^M'); 
  69.  
  70.   if (!waitfor ("after first RING",20)) 
  71.   { printsc ("Dial-back to number ");
  72.     printsc (phone);
  73.     prints (" failed!");
  74.     return -1;
  75.   }
  76.  
  77.   hangup();
  78.   while (carrier())
  79.     terminal();                          // Wait till offline.
  80.  
  81.   for (i=0; i<5; ++i)
  82.   { cputs_tr ("+++~~ATH0^M");
  83.     if (waitfor ("OK",5)) break;         // Wait for "OK".
  84.   }
  85.  
  86.   for (i=0; i<3; ++i) 
  87.   { prints ("T²: Waiting for ring...");
  88.     j = waitfor ("RING",60);             // Wait a minute for ring.
  89.     if (j) break;             
  90.   }
  91.  
  92.   if (j) 
  93.   { t1 = track (_connect_str,1);
  94.     t2 = track ("NO CARRIER",0);
  95.     do
  96.     { tmark = timer_start (tol);         // Wait 30 seconds.
  97.       cputs_tr ("+++~~ATA^M");           // Send auto-answer command.
  98.       while ((i=track_hit(0))==0)        // Get response.
  99.       terminal();
  100.     } while (i != t1 && !carrier());
  101.     release();                           // Free tracks.
  102.   }
  103.   else 
  104.   { prints ("T²: No ring in 3 minutes!");
  105.     return -1;
  106.   }
  107.  
  108.   waitfor (_connect_str,30);             // Wait for connect string.
  109.  
  110.   if (!carrier()) 
  111.   { prints ("T²: No CONNECT in 30 seconds!");
  112.     return -1;
  113.   }
  114.  
  115.   waitfor (command,30);
  116.   return 0;
  117. }
  118.                                          
  119. //-----------------------------------------------------------
  120. // Wrong BBS type.
  121. //-----------------------------------------------------------
  122.  
  123. wrongBBS()
  124. {
  125. str help[48];
  126.  
  127.     failtone();                          // Alarm.    
  128.     help = "This script is for ";        // Catenate strings.
  129.     strcat (help,thisBBStype);
  130.     strcat (help," only!");
  131.     status_wind (help,20);               // Display message for 2 sec.
  132. }
  133.  
  134. //-----------------------------------------------------------
  135. // Flush incoming text from BBS.
  136. //-----------------------------------------------------------
  137.  
  138. flush()
  139. {
  140.   do 
  141.   { terminal();                      // Process all echo
  142.     delay(1);                        // from the BBS.
  143.   } while (cinp_cnt() > 0);
  144. }
  145.  
  146. //-----------------------------------------------------------
  147. // Play fail tone.
  148. //-----------------------------------------------------------
  149.  
  150.  failtone()
  151. {
  152.   int n;
  153.   for (n=140; n > 10; n = 100*n/120) 
  154.   { tone(n*10,12);                       // Fail tone!!
  155.     terminal();                          // Process text.
  156.   }
  157. }
  158.  
  159. //-----------------------------------------------------------
  160. // Routine to update colors and status bar.
  161. //-----------------------------------------------------------
  162.  
  163. entry ()
  164. {
  165.   _back_color = 1;
  166.   _fore_color = 14;
  167.   update_term();
  168. }
  169.  
  170. //-----------------------------------------------------------
  171. // Read a global variable.
  172. //-----------------------------------------------------------
  173.  
  174. read (str name, str varname)
  175. {
  176.   return (call (global,"R",name,varname));
  177. }
  178.  
  179. //-----------------------------------------------------------
  180. // Free timer and tracking functions.
  181. //-----------------------------------------------------------
  182.  
  183. release()
  184. {
  185.   timer_free (tmark);                    // free timer channel
  186.   track_free (0);                        // and all track channels.
  187. }
  188.